﻿using System.Diagnostics;
using HalalCheck.View;
using HalalCheck.ViewModels;
using Xamarin.Forms;
using XLabs.Forms.Mvvm;
using XLabs.Ioc;
using XLabs.Platform.Mvvm;

namespace HalalCheck
{
    public class App : Application
    {
        public App()
        {
            Init();
            Root =new Root();
            MainPage = Root;

        }

        /// <summary>
        /// Initializes the application.
        /// </summary>
        public static void Init()
        {

            var app = Resolver.Resolve<IXFormsApp>();
            if (app == null)
            {
                return;
            }

            app.Closing += (o, e) => Debug.WriteLine("Application Closing");
            app.Error += (o, e) => Debug.WriteLine("Application Error");
            app.Initialize += (o, e) => Debug.WriteLine("Application Initialized");
            app.Resumed += (o, e) => Debug.WriteLine("Application Resumed");
            app.Rotation += (o, e) => Debug.WriteLine("Application Rotated");
            app.Startup += (o, e) => Debug.WriteLine("Application Startup");
            app.Suspended += (o, e) => Debug.WriteLine("Application Suspended");


            // Register our views with our view models
            ViewFactory.Register<HalalListPage, HalalListViewModel>();
            ViewFactory.Register<AllahNamesPage, AllahNamesViewModel>();
            ViewFactory.Register<MenuPage,MenuViewModel>();
            ViewFactory.Register<SalahPage, SalahViewModel>();
            ViewFactory.Register<QuranPage,QuranViewModel>();
            ViewFactory.Register<HalalItemPage, HalalItemViewModel>();
            ViewFactory.Register<SharePage,ShareViewModel>();
            ViewFactory.Register<LiveMakkahPage,LiveMakkahViewModel>();
            ViewFactory.Register<LiveMadinaPage,LiveMadinaViewModel>();
            ViewFactory.Register<ChecknSharePage,ChecknShareViewModel>();
        }

        static string _Token;
        public static Root Root;

        public static string Token
        {
            get { return _Token; }
        }

        public static void SaveToken(string token)
        {
            _Token = token;
        }
    }
}
